**********ILLINOIS TRAFFIC STOP DATA SERIES 2004-2011**********

*To be used with "Illinois-Traffic-Stop-Series.dta"


*********ILLINOIS VARIABLE CODING*******

*week: The main time variable, Stata's default function for weeks.

*Year: The year of the observation used for graphical display.

*gant_intervention: A step function the captures the impact of Gant. Takes the value of 0 up to the week of the decision (April 21st, 2009) and 1 after that week.

*search_incident_to_arrest: The weekly number of vehicle searches incident to arrest performed.

*other_search: The weekly number of vehicle searches labeled as the type "other."
	*note: this variable was not included until 2007 by the State of Illinois

*consent_search: The weekly number of vehicle searches labeled as the type "consent."
	
*dog_search: The weekly number of vehicle searches labeled as the type "dog search."

*probable_cause: The weekly number of vehicle searches labeled as the type "probable cause."

*reasonable_suspicion: The weekly number of vehicle searches labeled as the type "reasonable suspicion."

*seasonal_fe_#: Seasonal fixed effects for groups of four weeks within a year.

*year_2004: A dummy variable for the year 2004 used in the consent search model in the appendix of non-significant results.


*ILLINOIS SUMMARY STATISTICS
	
****Table 2: Summary Statistics for Illinois Search Series****
*pre-gant mean
summarize search_incident_to_arrest if gant_intervention==0
*post-gant mean
summarize search_incident_to_arrest if gant_intervention==1
*standard deviation, minimum and maximum values
summarize search_incident_to_arrest
*pre-gant mean
summarize consent_search if gant_intervention==0
*post-gant mean
summarize consent_search if gant_intervention==1
*standard deviation, minimum and maximum values
summarize consent_search
*pre-gant mean
summarize probable_cause if gant_intervention==0
*post-gant mean
summarize probable_cause if gant_intervention==1
*standard deviation, minimum and maximum values
summarize probable_cause
*pre-gant mean
summarize reasonable_suspicion if gant_intervention==0
*post-gant mean
summarize reasonable_suspicion if gant_intervention==1
*standard deviation, minimum and maximum values
summarize reasonable_suspicion
*pre-gant mean
summarize other_search if gant_intervention==0
*post-gant mean
summarize other_search if gant_intervention==1
*standard deviation, minimum and maximum values
summarize other_search
*pre-gant mean
summarize dog_search if gant_intervention==0
*post-gant mean
summarize dog_search if gant_intervention==1
*standard deviation, minimum and maximum values
summarize dog_search
*pre-gant N
count if gant_i==0
*post-gant N
count if gant_i==1


*ILLINOIS DESCRIPTIVE GRAPHS

****Figure 1: Illinois search incident to arrest series***
twoway (line search_incident_to_arrest Year), title("Figure 1: Illinois search incident to arrest series")  graphregion(color(white))  ylabel(250(250)2250, angle(0) grid gmin gmax labsize(medlarge)) xlabel(#10, labsize(medlarge)) ytitle(Weekly Searches Incident to Arrest  ,size(medlarge)) xtitle(Year, size(medlarge)) xline(18008, lpattern(dash))


****Figure 5: Illinois alternative search series****
*consent
twoway (line consent_search Year), title(Consent Searches) ytitle(Weekly Consent Searches  ,size(medlarge)) xtitle(Year, size(medlarge))  graphregion(color(white))  ylabel(#8, angle(0) grid gmin gmax labsize(medlarge)) xlabel(#10, labsize(medlarge)) xline(18008, lpattern(dash))
*dog
twoway (line dog_search Year), title(Dog Searches) ytitle(Weekly Dog Searches  ,size(medlarge)) xtitle(Year, size(medlarge))  graphregion(color(white))  ylabel(#8, angle(0) grid gmin gmax labsize(medlarge)) xlabel(#10, labsize(medlarge)) xline(18008, lpattern(dash))
*other
*note: preserve included so the data can be restored to the longer series later after the drop, other searches begin in 2007.
preserve
drop if missing(other_search)
twoway (line other_search Year), title(Other Searches) ytitle(Weekly Other Searches  ,size(medlarge)) xtitle(Year, size(medlarge))  graphregion(color(white))  ylabel(#6, angle(0) grid gmin gmax labsize(medlarge)) xlabel(#6, labsize(medlarge)) xline(18008, lpattern(dash))
restore
*probable cause
twoway (line probable_cause Year), title(Probable Cause Searches) ytitle(Weekly Probable Cause Searches  ,size(medlarge)) xtitle(Year, size(medlarge))  graphregion(color(white))  ylabel(100(25)275, angle(0) grid gmin gmax labsize(medlarge)) xlabel(#10, labsize(medlarge)) xline(18008, lpattern(dash))
*reasonable
twoway (line reasonable_suspicion Year), title(Reasonable Suspicion Searches) ytitle(Weekly Reasonable Suspicion Searches  ,size(medlarge)) xtitle(Year, size(medlarge))  graphregion(color(white))  ylabel(#8, angle(0) grid gmin gmax labsize(medlarge)) xlabel(#10, labsize(medlarge)) xline(18008, lpattern(dash))


*ILLINOIS ARTICLE BODY MODELS AND PREDICTED VALUES GRAPHS


**Search Incident to Arrest Model and Predicted Values Figure**
****Table 4: ARIMA/ARCH Model, Illinois Search Incident to Arrest Series****
arch d.search_incident_to_arrest d.gant_intervention d.seasonal_fe_2 d.seasonal_fe_3 d.seasonal_fe_4 d.seasonal_fe_5 d.seasonal_fe_6 d.seasonal_fe_7 d.seasonal_fe_8 d.seasonal_fe_9 d.seasonal_fe_10 d.seasonal_fe_11 d.seasonal_fe_12 d.seasonal_fe_13, ar(1 12) ma(1) arch(1) garch(1 2) het(gant_i)
*Q-test
predict e, res
wntestq e, lag(53)
drop e
*graph elements
predict ihat, y
predict fvar, var
generate ub=ihat + 1.96*sqrt(fvar)
generate lb=ihat - 1.96*sqrt(fvar)
*Figure 3: Predicted values from ARIMA/ARCH model, Illinois search incident to arrest series
twoway (rarea lb ub Year if gant_i==0  , astyle(ci)) (rarea lb ub Year if gant_i==1  , astyle(ci)) (scatter search_incident_to_arrest Year, msymbol(smcircle_hollow) mcolor(gs7) msize(small)) (line ihat Year if gant_i==0, lpattern(solid)) (line ihat Year if gant_i==1, lpattern(solid)), xline(18008) legend(label(4 "Predicted value") label(3 "Actual value") label(1 "95% confidence interval")  order(4 3 1)cols(3) size(small)) title("Figure 3: Predicted values from ARIMA/ARCH model") subtitle(Illinois search incident to arrest series) ytitle(Weekly Searches Incident to Arrest)  graphregion(color(white))  ylabel(500(250)2500, angle(0) grid gmin gmax) xlabel(#10)
drop ihat fvar ub lb 



**Other Searches Model and Predicted Values Figure**
*note: preserve included so the data can be restored to the longer series later after the drop, other searches begin in 2007.
preserve
drop if missing(other_search)
****Table 6: ARIMA/ARCH Model, Illinois Other Search Series****
arch other_search gant_in seasonal_fe_2 seasonal_fe_3 seasonal_fe_4 seasonal_fe_5 seasonal_fe_6 seasonal_fe_7 seasonal_fe_8 seasonal_fe_9 seasonal_fe_10 seasonal_fe_11 seasonal_fe_12 seasonal_fe_13, arima(2,1,0) arch(1) garch(1) het(gant_intervention) 
*Q-test
predict e, res
wntestq e, lag(53)
drop e
*graph elements
predict ihat, y
predict fvar, var
generate ub=ihat + 1.96*sqrt(fvar)
generate lb=ihat - 1.96*sqrt(fvar)
*Figure 7: Predicted values from ARCH/ARIMA model, Illinois other search series
twoway (rarea lb ub Year if gant_i==0  , astyle(ci)) (rarea lb ub Year if gant_i==1  , astyle(ci))  (scatter other_search Year, msymbol(smcircle_hollow) mcolor(gs7) msize(small)) (line ihat Year if gant_i==0, lpattern(solid)) (line ihat Year if gant_i==1, lpattern(solid)), legend(label(4 "Predicted value") label(3 "Actual value") label(1 "95% confidence interval")  order(4 3 1)cols(3) size(small)) title("Figure 7: Predicted values from ARIMA/ARCH model") subtitle(Illinois other search series) ytitle(Weekly Other Searches) xline(18008) graphregion(color(white)) ylabel(#9, angle(0) grid gmin gmax) xlabel(17167(366)18980)
drop ihat fvar ub
restore


*ILLINOIS APPENDIX: NON-SIGNIFICANT ALTERNATIVE SEARCH MODELS


*Table 7: ARIMA/ARCH Model of Illinois Consent Search Series
arch consent_search  gant_intervention seasonal_fe_2 seasonal_fe_3 seasonal_fe_4 seasonal_fe_5 seasonal_fe_6 seasonal_fe_7 seasonal_fe_8 seasonal_fe_9 seasonal_fe_10 seasonal_fe_11 seasonal_fe_12 seasonal_fe_13 year_2004, arima(1,0,1)  arch(1) garch(1 2) 
*Q-test
predict e, res
wntestq e, lag(53)
drop e

*Table 8: ARIMA/ARCH Model of Illinois Dog Search Series
arch dog_search gant_intervention seasonal_fe_2 seasonal_fe_3 seasonal_fe_4 seasonal_fe_5 seasonal_fe_6 seasonal_fe_7 seasonal_fe_8 seasonal_fe_9 seasonal_fe_10 seasonal_fe_11 seasonal_fe_12 seasonal_fe_13, arima(1,1,1)  arch(1) garch(1)
*Q-test
predict e, res
wntestq e, lag(53)
drop e

*Table 9: ARIMA/ARCH Model of Illinois Probable Cause Series
arch probable_cause gant_intervention seasonal_fe_2 seasonal_fe_3 seasonal_fe_4 seasonal_fe_5 seasonal_fe_6 seasonal_fe_7 seasonal_fe_8 seasonal_fe_9 seasonal_fe_10 seasonal_fe_11 seasonal_fe_12 seasonal_fe_13, arima(1,1,1)  arch(1 2) garch(1 2) 
*Q-test
predict e, res
wntestq e, lag(53)
drop e

*Table 10: ARIMA/ARCH Model of Illinois Reasonable Suspicion Series
arch  reasonable_suspicion gant_intervention seasonal_fe_2 seasonal_fe_3 seasonal_fe_4 seasonal_fe_5 seasonal_fe_6 seasonal_fe_7 seasonal_fe_8 seasonal_fe_9 seasonal_fe_10 seasonal_fe_11 seasonal_fe_12 seasonal_fe_13, arima(0,1,1) arch(1) garch(1)
*Q-test
predict e, res
wntestq e, lag(53)
drop e





****************************************************************************************************************
****************************************************************************************************************
****************************************************************************************************************
****************************************************************************************************************





**********NORTH CAROLINA TRAFFIC STOP DATA SERIES 2003-2014**********

*To be used with "North-Carolina-Traffic-Stop-Series.dta"


*********NORTH CAROLINA VARIABLE CODING*******

*week: The main time variable, Stata's default function for weeks.

*Year: The year of the observation used for graphical display.

*gant_intervention: A step function the captures the impact of Gant. Takes the value of 0 up to the week of the decision (April 21st, 2009) and 1 after that week.

*search_incident_to_arrest: The weekly number of vehicle searches incident to arrest performed.

*consent_search: The weekly number of vehicle searches labeled as the type "consent."
	
*warrant_search: The weekly number of vehicle searches labeled as the type "warrant search."

*probable_cause: The weekly number of vehicle searches labeled as the type "probable cause."

*protective_search: The weekly number of vehicle searches labeled as the type "protective search."

*post_2010: A dummy variable to control for an unknown shock occurring in 2010. Takes the value of 1 on the first week of 2010 and thereafter.

*gant_short: In order to account for a sudden increase in the series in 2010, this short Gant intervention variable takes the value of 1 after the week of the decision, but only prior to the end of 2009. To be used with the post_2010 variable.

*trend: A counter of weeks that captures a linear trend.

*seasonal_fe_#: Seasonal fixed effects for groups of four weeks within a year.




*NORTH CAROLINA SUMMARY STATISTICS

****Table 3: Summary Statistics for North Carolina Search Series****
*pre-gant mean
summarize search_incident_to_arrest if gant_i==0
*post-gant mean
summarize search_incident_to_arrest if gant_i==1
*standard deviation, minimum and maximum values
summarize search_incident_to_arrest 
*pre-gant mean
summarize consent_search if gant_i==0
*post-gant mean
summarize consent_search if gant_i==1
*standard deviation, minimum and maximum values
summarize consent_search
*pre-gant mean
summarize probable_cause if gant_i==0
*post-gant mean
summarize probable_cause if gant_i==1
*standard deviation, minimum and maximum values
summarize probable_cause
*pre-gant mean
summarize protective_search if gant_i==0
*post-gant mean
summarize protective_search if gant_i==1
*standard deviation, minimum and maximum values
summarize protective_search
*pre-gant mean
summarize warrant_search if gant_i==0
*post-gant mean
summarize warrant_search if gant_i==1
*standard deviation, minimum and maximum values
summarize warrant_search
*pre-gant N
count if gant_i==0
*post-gant N
count if gant_i==1


*NORTH CAROLINA DESCRIPTIVE GRAPHS

****Figure 2: North Carolina search incident to arrest series***
twoway (line search_incident_to_arrest Year), title("Figure 2: North Carolina search incident to arrest series")  graphregion(color(white))  ylabel(#10, angle(0) grid gmin gmax labsize(medlarge)) xlabel(15706(731)19905, labsize(medlarge)) ytitle(Weekly Searches Incident to Arrest  ,size(medlarge)) xtitle(Year, size(medlarge)) xline(18008, lpattern(dash))

****Figure 6: North Carolina alternative search series****
*consent
twoway (line consent_search Year), title(Consent Searches) ytitle(Weekly Consent Searches) xtitle(Year)  graphregion(color(white))  ylabel(100(100)600, angle(0) grid gmin gmax) xlabel(15706(731)19905) xline(18008, lpattern(dash))
*probable cause
twoway (line probable_cause Year), title(Probable Cause Searches) ytitle(Weekly Probable Cause Searches) xtitle(Year)  graphregion(color(white))  ylabel(#8, angle(0) grid gmin gmax) xlabel(15706(731)19905) xline(18008, lpattern(dash))
*protective search
twoway (line protective_search Year), title(Protective Searches) ytitle(Weekly Protective Searches  ) xtitle(Year)  graphregion(color(white))  ylabel(#8, angle(0) grid gmin gmax ) xlabel(15706(731)19905) xline(18008, lpattern(dash))
*search warrant
twoway (line warrant_search Year), title(Warrant Searches) ytitle(Weekly Warrant Searches  ) xtitle(Year)  graphregion(color(white))  ylabel(#8, angle(0) grid gmin gmax ) xlabel(15706(731)19905) xline(18008, lpattern(dash))

*NORTH CAROLINA ARTICLE BODY MODELS AND PREDICTED VALUES FIGURES

**Search Incident to Arrest Model and Predicted Values Figure**
****Table 5: ARIMA/ARCH Model, North Carolina Search Incident to Arrest Series****
arch d.search_incident_to_arrest d.gant_i d.seasonal_fe_2 d.seasonal_fe_3 d.seasonal_fe_4 d.seasonal_fe_5 d.seasonal_fe_6 d.seasonal_fe_7 d.seasonal_fe_8 d.seasonal_fe_9 d.seasonal_fe_10 d.seasonal_fe_11 d.seasonal_fe_12 d.seasonal_fe_13, ar(1 2 3 4 5 6 14) ma(1 2 3) arch(1) garch(1 2 3) het(gant_i)
*Q-test
predict e, res
wntestq e, lag(53)
drop e
*graph elements
predict ihat, y
predict fvar, var
generate ub=ihat + 1.96*sqrt(fvar)
generate lb=ihat - 1.96*sqrt(fvar)
*Figure 4: Predicted values from ARIMA/ARCH Model, North Carolina search incident to arrest series
twoway (rarea lb ub Year if gant_i==0  , astyle(ci)) (rarea lb ub Year if gant_i==1  , astyle(ci)) (scatter search_incident_to_arrest Year, msymbol(smcircle_hollow) mcolor(gs7) msize(small)) (line ihat Year if gant_i==0, lpattern(solid)) (line ihat Year if gant_i==1, lpattern(solid)), xline(18008) legend(label(4 "Predicted value") label(3 "Actual value") label(1 "95% confidence interval")  order(4 3 1)cols(3) size(small)) title("Figure 4: Predicted values from ARIMA/ARCH model") subtitle(North Carolina search incident to arrest series) ytitle(Weekly Searches Incident to Arrest)  graphregion(color(white))  ylabel(#10, angle(0) grid gmin gmax) xlabel(#10)
drop ihat fvar ub lb 


*NORTH CAROLINA APPENDIX: NON-SIGNIFICANT ALTERNATIVE SEARCH MODELS

*Table 11: ARIMA/ARCH Model of North Carolina Consent Search Series
arch d.consent_search d.gant_i d.seasonal_fe_2 d.seasonal_fe_3 d.seasonal_fe_4 d.seasonal_fe_5 d.seasonal_fe_6 d.seasonal_fe_7 d.seasonal_fe_8 d.seasonal_fe_9 d.seasonal_fe_10 d.seasonal_fe_11 d.seasonal_fe_12 d.seasonal_fe_13, ar(1 2 10) ma(1 2 3) arch(1) garch(1 2 3) 
*Q-test
predict e, res
wntestq e, lag(53)
drop e
*Table 12: ARIMA/ARCH Model of North Carolina Probable Cause Search Series
arch probable_cause gant_short post_2010 seasonal_fe_2 seasonal_fe_3 seasonal_fe_4 seasonal_fe_5 seasonal_fe_6 seasonal_fe_7 seasonal_fe_8 seasonal_fe_9 seasonal_fe_10 seasonal_fe_11 seasonal_fe_12 seasonal_fe_13 trend, ar(1 2 3 4 24) ma(1 2)  arch(1) garch(1 2 3 4) het(post_2010)
*Q-test
predict e, res
wntestq e, lag(53)
drop e
*Table 13: ARIMA/ARCH Model of North Carolina Protective Search Series
arch protective_search gant_short post_2010  seasonal_fe_2 seasonal_fe_3 seasonal_fe_4 seasonal_fe_5 seasonal_fe_6 seasonal_fe_7 seasonal_fe_8 seasonal_fe_9 seasonal_fe_10 seasonal_fe_11 seasonal_fe_12 seasonal_fe_13, arima(0,1,1) arch(1) garch(1 2 3 4)
*Q-test
predict e, res
wntestq e, lag(53)
drop e












